<meta charset="utf-8"/>
<script>	
	var score=0;
	var num = prompt("请输入考试科目的数量：");  
		while(isNaN(num)){
		alert("不是数字！");
		num = prompt("请重新输入");
			}
			while(num<=0){
				alert("输入的考试科目非负数！");
				num = prompt("请重新输入");
			}
			for(var i = 1;i<=num;i++){
				var chengji = prompt("请输入第"+i+"门课成绩");
				while (isNaN(chengji)){
					alert("不是数字！");
					chengJi = prompt("请重新输入");
				}
				while(chengji<0){
					alert("成绩不能为负数！");
					chengji = prompt("请重新输入成绩");
				}
				score+=parseFloat(chengji);	
			}
			alert(num+"门科目的总成绩是："+score);
			


</script>